<template>
  <div class="lyrics">
    <div class="mask"></div>
    <div class="ly_box">
      {{ lyrics }}
    </div>
    <div class="close" @click="showLyrics">
      <i class="iconfont icon-close"></i>
    </div>
  </div>
</template>
<script>
import { mapGetters } from "vuex"
export default {
  data() {
    return {
      lyrics: "",
    }
  },
  created() {
    this.lyrics = this.getName + "--" + this.getAuthor
  },
  computed: {
    // vue辅助函数
    ...mapGetters(["getName", "getAuthor", "getLyrics", "getLyricsIndex"]),
  },
  watch: {
    getLyricsIndex: function(newValue, oldValue) {
      this.lyrics = this.getLyrics[newValue][1]
    },
  },
  methods: {
    showLyrics() {
      this.$store.commit("changeShowLyrics")
    },
  },
}
</script>
<style lang="scss" scoped>
.lyrics {
  position: fixed;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-block;
  width: auto;
  min-height: 50px;
  background: transparent;
  z-index: 9999;
  border-radius: 5px;
  box-sizing: border-box;
  padding: 5px;
  .mask {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    background: rgb(0, 0, 0);
    opacity: 0.6;
    z-index: 1;
    border-radius: 5px;
    // border-top-right-radius: none;
    // border-top-left-radius: 5px;
    // border-bottom-left-radius: 5px;
    // border-bottom-right-radius: 5px;
  }
  .ly_box {
    border-radius: 5px;
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    // min-width: calc(100% - 40px);
    width: calc(100% - 40px);
    padding: 0px 10px;
    box-sizing: border-box;
    z-index: 2;
    color: white;
    font-size: 20px;
    text-align: center;
    line-height: 50px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .close {
    border-top-left-radius: 5px;
    border-top-right-radius: 5px;
    position: absolute;
    top: 0px;
    right: 0px;
    height: 100%;
    width: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 5;
    i {
      color: white;
      font-size: 15px;
      transition: 0.5s;
    }
  }
  .close:hover {
    cursor: pointer;
  }
  .close:hover i {
    color: #c20c0c;
  }
}
@media (min-width: 1200px) {
  .lyrics {
    width: 40vw;
    max-width: 1200px;
  }
}
@media (min-width: 600px) and (max-width: 1200px) {
  .lyrics {
    width: 50vw;
  }
}
@media (max-width: 600px) {
  .lyrics {
    width: 90vw;
  }
}
</style>
